import http from "@/utils/http";
import type { AddReferenceParams, TaskNameItem } from "./types";

/**
 * 搜索任务名称
 */
type TaskNameParams = { taskSettingId: string; taskName?: string };
export const searchTaskName = (params: TaskNameParams) => {
  return http.get<TaskNameItem[]>("crm/reference/getReferenceTask", params);
};

/**
 * 待办任务参考预览数据
 */
export const previewFormsList = (stageTaskId: string) => {
  return http.get(`crm/reference/toTaskPreview/${stageTaskId}`);
};
/**
 * 任务空表单预览
 */
export const previewTaskForm = (referenceTaskSettingId: number | string) => {
  return http.get(`crm/reference/taskPreview/${referenceTaskSettingId}`);
};

/**
 * 新增参考模板
 */
export const addReferenceData = (taskSettingId: string, data: AddReferenceParams[]) => {
  return http.post(`crm/reference/add/${taskSettingId}`, data);
};

/**
 * 参考任务列表
 */
export const referenceList = (taskSettingId: string) => {
  return http.get<TaskNameItem[]>(`crm/reference/list/${taskSettingId}`);
};
